from flask import render_template

from blueprint import page
from model.crud import QueryOneInstance
from model.tables import Blog
from restful.error import RenderPostNotExist
from restful.session import current_user_required


@page.route('/front/publish/<int:pid>',methods=['GET'])
@current_user_required
def front_edit_old(pid,current_user):
    blog = QueryOneInstance(Blog, {'uid':current_user.id, 'id':pid})
    if not blog:
        return RenderPostNotExist(pid)
    return render_template('front/publish.html', pid=pid, blog=blog)

@page.route('/front/publish',methods=['GET'])
@current_user_required
def front_publish_new(current_user):
    return render_template('front/publish.html')
